home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / sbprolog / amiga / v3_1 / sbp3_1e.lzh / STRUCTUR.PL < prev    next >
Text File  |  1991-10-31  |  1KB  |  38 lines

  1. /* From the book PROLOG PROGRAMMING IN DEPTH
  2.    by Michael A. Covington, Donald Nute, and Andre Vellino.
  3.    Copyright 1988 Scott, Foresman & Co.
  4.    Non-commercial distribution of this file is permitted. */
  5. /* Modified for Quintus Prolog by Andreas Siebert */
  6.  
  7. /* STRUCTUR.PL */
  8.  
  9. /* Queries will use built-in predicate phrase/2 */
  10.  
  11. /* This parser implements the same grammar
  12.    as PARSER2.PL, but builds a representation
  13.    of the parse tree while parsing. */
  14.  
  15. sentence(sentence(X,Y)) -->
  16.    noun_phrase(X), verb_phrase(Y).
  17.  
  18. noun_phrase(noun_phrase(X,Y)) -->
  19.    determiner(X), noun(Y).
  20.  
  21. verb_phrase(verb_phrase(X,Y)) -->
  22.    verb(X), noun_phrase(Y).
  23. verb_phrase(verb_phrase(X,Y)) -->
  24.    verb(X), sentence(Y).
  25.  
  26. determiner(determiner(the)) --> [the].
  27. determiner(determiner(a)) --> [a].
  28.  
  29. noun(noun(dog)) --> [dog].
  30. noun(noun(cat)) --> [cat].
  31. noun(noun(boy)) --> [boy].
  32. noun(noun(girl)) --> [girl].
  33.  
  34. verb(verb(chased)) --> [chased].
  35. verb(verb(saw)) --> [saw].
  36. verb(verb(said)) --> [said].
  37. verb(verb(believed)) --> [believed].
  38.